import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  // path 和 name是两种导航的形式，现在记住path就行
  // name 可以删掉
  routes: [
    {
      path: '/',
      // name: 'home',
      component: HomeView,
    },
    {
      path: '/about',
      // name: 'about',
      // 懒加载
      component: () => import('../views/AboutView.vue'),
      children: [
        {
          path: '',
          component: () => import('../views/About1.vue')
        },
        {
          path: '/about/about2',
          component: () => import('../views/About2.vue')
        },
      ]
    },
    {
      path: '/login',
      // name: 'login',
      // 懒加载
      component: () => import('../views/Login.vue'),
    },
    {
      path: '/todolist',
      component: () => import('../views/ToDoList.vue'),
    },
  ],
})

export default router
